package com.pucong.gitee.database.backup.business.database.util;

import com.pucong.gitee.database.backup.common.entity.database.AutoDataSource;
import com.pucong.gitee.database.backup.common.selfenum.DatabaseTypeEnum;
import com.pucong.gitee.database.backup.business.database.mapper.AutoExeSqlLogMapper;

public class BackupServiceFactory {

    /**
     * 工厂生产sql执行器
     * @param autoDataSource
     * @param autoExeSqlLogMapper
     * @return
     */
    public OperationService getBackupService(AutoDataSource autoDataSource, AutoExeSqlLogMapper autoExeSqlLogMapper) {
        DatabaseTypeEnum databaseType = autoDataSource.getDatabaseType();
        OperationService operationService = null;
        switch (databaseType){
            case oracle:
                operationService = new OperationServiceOracleImpl(autoDataSource, autoExeSqlLogMapper);
                break;
            case mysql:
                operationService = new OperationServiceMysqlImpl(autoDataSource, autoExeSqlLogMapper);
                break;
            case postgresql:
                operationService = new OperationServicePgsqlImpl(autoDataSource, autoExeSqlLogMapper);
                break;
            case sqlserver:
                operationService = new OperationServiceMssqlImpl(autoDataSource, autoExeSqlLogMapper);
                break;
            case hive:
                operationService = new OperationServiceHivelImpl(autoDataSource, autoExeSqlLogMapper);
                break;
        }
        return operationService;
    }

}